﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ITAP.ShprossesBuilder.Modelling;
using ITAP.ShprossesBuilder.Modelling.Components.Actions;
using ITAP.ShprossesBuilder.Modelling.Components;
using ITAP.ShprossesBuilder.Editor;
using ITAP.ShprossesBuilder.Properties;

namespace ITAP.ShprossesBuilder.Operations
{
    public class OperationAlignSelectedShprossesByAngle : IOperation
    {
        #region IOperation Members

        public string Name
        {
            get { return "Выравнивание профилей по углу"; }
        }

        public void Execute(ModelControl modelControl)
        {
            AlignShprossesByAngleForm alignForm = new AlignShprossesByAngleForm();
            if (alignForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                foreach (IComponent selectedComponent in modelControl.ModelContainer.SelectedComponentsStack)
                {
                    if (selectedComponent is Shpross)
                    {
                        IComponentAction action = new ActionAlignSelectedShprossesAngles(modelControl, alignForm.Angle);
                        action.Action(selectedComponent);
                        break;
                    }
                }
            }        
        }

        #endregion

        #region IOperation Members


        public OperationGroup OperationGroup
        {
            get { return OperationGroup.ShprossOperation; }
        }

        #endregion

        #region IOperation Members


        public System.Drawing.Image Thumbnail
        {
            get { return Resources.AlignShprossesByAngle.ToBitmap(); }
        }

        #endregion

        #region IOperation Members


        public bool CanUndo
        {
            get { return true; }
        }

        #endregion
    }
}
